/**
 * Copyright (C), 2011-2016
 * File Name: ClientTrackServlet.java
 * Encoding: UTF-8
 * Date: Feb 29, 2012
 * History: 
 */
package com.waynewan.qcomet.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 
 * @author WayneWan (bestirwiny@gmail.com)
 * @Date Feb 29, 2012 9:41:47 PM
 */
public class ClientTrackServlet extends HttpServlet {
	private static Log log = LogFactory.getLog(ClientTrackServlet.class);
	private static final long serialVersionUID = -7148626213397133992L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		log.debug("add a client id to client!" );
		Cookie cookie = new Cookie("Q-Comet-ClientId" , req.getSession(true).getId());
		cookie.setMaxAge(3600*24*1000);
		resp.addCookie(cookie);
	}
}
